package com.kitty.web.controller;

import com.kitty.web.controller.BaseController;
import com.kitty.web.common.AjaxResult;
import com.kitty.web.core.page.TableDataInfo;
import com.kitty.web.domain.PXing;
import com.kitty.web.system.xing.service.IPXingService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.*;

import java.util.List;


/**
 * 怪物-星Controller
 * 
 * @author soul
 * @date 2022-03-29
 */
@Controller
@RequestMapping("/system/xing")
public class PXingController extends BaseController
{
    private String prefix = "system/xing";

    @Autowired
    private IPXingService pXingService;


    @GetMapping()
    public String xing()
    {
        return prefix + "/xing";
    }

    /**
     * 查询怪物-星列表
     */

    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(PXing pXing)
    {
        startPage();
        List<PXing> list = pXingService.selectPXingList(pXing);
        return getDataTable(list);
    }


    /**
     * 新增怪物-星
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存怪物-星
     */

    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(PXing pXing)
    {
        return toAjax(pXingService.insertPXing(pXing));
    }

    /**
     * 修改怪物-星
     */
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") Long id, ModelMap mmap)
    {
        PXing pXing = pXingService.selectPXingById(id);
        mmap.put("pXing", pXing);
        return prefix + "/edit";
    }

    /**
     * 修改保存怪物-星
     */

    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(PXing pXing)
    {
        return toAjax(pXingService.updatePXing(pXing));
    }

    /**
     * 删除怪物-星
     */

    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(pXingService.deletePXingByIds(ids));
    }
}
